package com.gitee.cirnochat.common.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum EmailSendType implements BaseEnum<Integer> {

    LOGIN_OR_REGISTER(0, "登陆"),
    RESET_PASSWORD(1, "密码设置"),
    OLD_EMAIL_CONFIRM(2, "老邮箱确认"),
    NEW_EMAIL_CONFIRM(3, "新邮箱确认");

    @JsonValue
    @EnumValue
    private final Integer value;
    private final String description;

    EmailSendType(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public static EmailSendType fromCode(Integer code) {
        for (EmailSendType type : values()) {
            if (Objects.equals(type.value, code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的邮箱类型: " + code);
    }
}
